The laws of thermodynamics put limits to the efficiencies of thermal machines. Analogues of these laws are now established for quantum engines weakly and passively coupled to the environment providing a framework to find improvements to their performance. Systems whose interaction with the environment is actively controlled do not fall in that framework. Here we consider systems actively and locally coupled to the environment, evolving with a so-called boundary-driven Lindblad equation. Starting from a unitary description of the system plus the environment we simultaneously obtain the Lindblad equation and the appropriate expressions for heat, work and entropy-production of the system extending the framework for the analysis of new, and some already proposed, quantum heat engines. We illustrate our findings in spin 1/2 chains and explain why an XX chain coupled in this way to a single heat bath relaxes to thermodynamic-equilibrium while and XY chain does not. Additionally, we show that an XX chain coupled to a left and a right heat baths behaves as a quantum engine, a heater or refrigerator depending on the parameters, with efficiencies bounded by Carnot efficiencies.
10 pages, 2 figures (minor correction in a formula in this new version)